package com.example.administrator.notification;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private Button button;
    private SharedPreferences sp;
    private TextView title, note, time;
    private String strTitle, strNote, strTime;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
        sp = getSharedPreferences("UserNote", MODE_PRIVATE);
    }

    @Override
    protected void onStart() {
        super.onStart();
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, AddActivity.class);
                startActivity(intent);
            }
        });
    }

    protected void onResume() {
        super.onResume();
        strTime = sp.getString("time", "null");
        strTitle = sp.getString("title", "null");
        strNote = sp.getString("text", "null");
        title.setText(strTitle);
        note.setText(strNote);
        time.setText(strTime);
        System.out.println("onResume");
    }

    public void init() {
        button = (Button) findViewById(R.id.bt);
        title = (TextView) findViewById(R.id.main_title);
        note = (TextView) findViewById(R.id.main_note);
        time = (TextView) findViewById(R.id.main_time);
    }


}
